package com.nbsaas.boot.wms.rest.convert;

import com.nbsaas.boot.wms.data.entity.Warehouse;
import com.nbsaas.boot.wms.api.domain.response.WarehouseResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 仓库-实体对象转化成响应对象
 */

public class WarehouseResponseConvert implements Converter<WarehouseResponse, Warehouse> {

    @Override
    public WarehouseResponse convert(Warehouse source) {
        WarehouseResponse result = new WarehouseResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getCatalog() != null) {
            result.setCatalog(source.getCatalog().getId());
        }

        try {
            if (source.getCatalog() != null) {
                result.setCatalogName(source.getCatalog().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

